package com.penglecode.netty.client;

import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;

import com.penglecode.netty.codec.protostuff.ProtostuffObjectDecoder;
import com.penglecode.netty.codec.protostuff.ProtostuffObjectEncoder;
import com.penglecode.protostuff.runtime.ObjectSerializer;
import com.penglecode.protostuff.runtime.ProtostuffSerializer;

public class NettyClientChannelPipelineFactory implements ChannelPipelineFactory {

	private ObjectSerializer serializer = new ProtostuffSerializer();
	
	public ChannelPipeline getPipeline() throws Exception {
		ChannelPipeline channelPipeline = Channels.pipeline();
		channelPipeline.addLast("clientdecoder", new ProtostuffObjectDecoder(serializer));
		channelPipeline.addLast("clientencoder", new ProtostuffObjectEncoder(serializer));
		channelPipeline.addLast("clienthandler", new NettyClientHandler());
		return channelPipeline;
	}

}
